import { createBrowserRouter } from 'react-router-dom'
import NotFound from '@/pages/pc/notfound'
// 自动导入模块中所有子文件
const modulesFiles = import.meta.glob('./modules/**.{ts,tsx}', { eager: true })
let dynameicRouter = []
for (const key of Object.keys(modulesFiles)) {
  if (modulesFiles[key].default !== undefined) {
    dynameicRouter.push(...modulesFiles[key].default)
  }
}
// 添加NOTFOUND页面
dynameicRouter = dynameicRouter.concat([
  {
    path: '*',
    element: <NotFound></NotFound>,
  },
])
export default createBrowserRouter(dynameicRouter)
